Skip to content

refactor(components): extract useWorkspaceClipboardPacks + useGuidedRunbook#57

Merged
saagpatel merged 1 commit into
masterfrom
codex/refactor/wave5-7-draft-followup
Apr 21, 2026
Merged

refactor(components): extract useWorkspaceClipboardPacks + useGuidedRunbook#57
saagpatel merged 1 commit into
masterfrom
codex/refactor/wave5-7-draft-followup

Conversation

@saagpatel
Copy link
Copy Markdown
Owner

What

Two follow-up DraftTab extractions:

  • `useWorkspaceClipboardPacks` — the three handoff/evidence/KB-draft clipboard handlers (`handleCopyHandoffPack`, `handleCopyEvidencePack`, `handleCopyKbDraft`). ~100 LOC of handler + deps out of the shell.
  • `useGuidedRunbook` — the four guided-runbook callbacks (`handleStartGuidedRunbook`, `handleAdvanceGuidedRunbook`, `handleCopyRunbookProgressToNotes`, `handleGuidedRunbookNoteChange`) plus the `guidedRunbookNote` state. ~170 LOC of handler + deps out of the shell.

Shell reduction: 2127 → 1893 LOC (-234, ~11% on this PR).

Why

These are the two cleanest remaining hook concerns in DraftTab that don't cross-cut the draft-content state web (response / sources / metrics / confidence / grounding / caseIntake). Each is self-contained with a short argument list. Extracting them is low-risk and brings the shell materially closer to the ≤1000 LOC Wave 5 success target (now at 1893).

The bigger remaining extraction, `useDraftPersistence` (wrapping `handleSaveDraft` + `handleLoadDraft` + autosave), touches 20+ shell state setters and was deferred in the verification pass — it deserves its own PR rather than a parallel teammate.

How

  1. Create `useWorkspaceClipboardPacks.ts` with the three copy handlers. Hook takes pack memos + saveCaseOutcome + logEvent + handoff-touched callback + toast callbacks.
  2. Create `useGuidedRunbook.ts` with the four callbacks. Hook owns `guidedRunbookNote` state; takes the ops callbacks (start/advance/addEvidence), the shell's workspace-level setters (diagnostic notes, panel density, runbook session scope/touched), and toast callbacks.
  3. Update `DraftTab.tsx` to consume both hooks. Reorder the guided-runbook hook call earlier in the component body so `buildDiagnosisJson`'s dep array can reference `guidedRunbookNote`.
  4. Add `useWorkspaceClipboardPacks.test.ts` (4 tests) and `useGuidedRunbook.test.ts` (5 tests).

Testing

  • `pnpm tsc --noEmit` — clean.
  • `pnpm test` — 214 pass (was 205; +9 new hook tests across 2 files).
  • `pnpm ui:gate:static` — exit 0.

Risk / Notes

  • `DraftTabHandle` interface unchanged (still pinned by `DraftTab.handle.test.tsx`).
  • Behavior preserved: clipboard flow, guided-runbook start/advance/copy flow, note-change touched-tracking, all identical.
  • DraftTab.tsx still over the 700-LOC target — Wave 5 per-file targets documented as aspirational; success criterion of "no file >1000 LOC" remains the focus.

Pull the three handoff/evidence/kb-draft clipboard handlers into
useWorkspaceClipboardPacks and the four guided-runbook callbacks
(start, advance, copy-progress-to-notes, note-change) plus the
guidedRunbookNote state into useGuidedRunbook. Shell continues to
own panel density, diagnostic notes, and runbook session touched
state; hooks accept setters for cross-cutting writes.
@saagpatel saagpatel merged commit a65c4ab into master Apr 21, 2026
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants